<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>emp-toolkit: /Users/wangxiao/git/emp-toolkit/emp-tool/utils/com.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo-full-doxygen.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">emp-toolkit
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('com_8h_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">com.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="com_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef COM_H__</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define COM_H__</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &quot;string.h&quot;</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="hash_8h.html">hash.h</a>&quot;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="prg_8h.html">prg.h</a>&quot;</span></div><div class="line"><a name="l00010"></a><span class="lineno"><a class="line" href="group___b_p.html#ga76fbd0364c5ce56d51e33dbf4adc3643">   10</a></span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">char</span> <a class="code" href="group___b_p.html#ga76fbd0364c5ce56d51e33dbf4adc3643">Com</a>[20];</div><div class="line"><a name="l00011"></a><span class="lineno"><a class="line" href="group___b_p.html#gad6ff8abfdae07ce92ed2245f801fec34">   11</a></span>&#160;<span class="keyword">typedef</span> <a class="code" href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a> <a class="code" href="group___b_p.html#gad6ff8abfdae07ce92ed2245f801fec34">Decom</a>[1];</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div><div class="line"><a name="l00013"></a><span class="lineno"><a class="line" href="class_commitment.html">   13</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_commitment.html">Commitment</a>{ <span class="keyword">public</span>:</div><div class="line"><a name="l00014"></a><span class="lineno"><a class="line" href="class_commitment.html#abd804e39d27332e2928c636831b7fe1c">   14</a></span>&#160;    <a class="code" href="class_hash.html">Hash</a> <a class="code" href="class_commitment.html#abd804e39d27332e2928c636831b7fe1c">h</a>;</div><div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="class_commitment.html#a63ff1008e7b57827062ad4f290478ef3">   15</a></span>&#160;    <a class="code" href="class_p_r_g.html">PRG</a> <a class="code" href="class_commitment.html#a63ff1008e7b57827062ad4f290478ef3">prg</a>;</div><div class="line"><a name="l00016"></a><span class="lineno"><a class="line" href="class_commitment.html#a2149ce3516c3454b803ab97f45439a6e">   16</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="class_commitment.html#a2149ce3516c3454b803ab97f45439a6e">commit</a>(<a class="code" href="group___b_p.html#gad6ff8abfdae07ce92ed2245f801fec34">Decom</a> decom, <a class="code" href="group___b_p.html#ga76fbd0364c5ce56d51e33dbf4adc3643">Com</a> com, <span class="keyword">const</span> <span class="keywordtype">void</span> * message, <span class="keywordtype">int</span> nbytes) {</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;        prg.<a class="code" href="class_p_r_g.html#a822a2e39f1d2629b881ce9b3b8d66bf9">random_block</a>(decom, 1);</div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;        h.<a class="code" href="class_hash.html#a9c8d5864406c53c5ea83aa7bfb94c47d">reset</a>();</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;        h.<a class="code" href="class_hash.html#a86ad3dcd18b0b279d4039e4404a1043c">put_block</a>(decom, 1);</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;        h.<a class="code" href="class_hash.html#a4bb9da7bf411c5db9af391fc3ec74f81">put</a>(message, nbytes);</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;        h.<a class="code" href="class_hash.html#a574b6b0ef1b80eb4b15809cc15257a3f">digest</a>(com);</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    }</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;</div><div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="class_commitment.html#a5453ed33018f54af82ffedb25d711d66">   24</a></span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="class_commitment.html#a5453ed33018f54af82ffedb25d711d66">open</a>(<a class="code" href="group___b_p.html#gad6ff8abfdae07ce92ed2245f801fec34">Decom</a> decom, <a class="code" href="group___b_p.html#ga76fbd0364c5ce56d51e33dbf4adc3643">Com</a> com, <span class="keyword">const</span> <span class="keywordtype">void</span> * message, <span class="keywordtype">int</span> nbytes) {</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;        h.<a class="code" href="class_hash.html#a9c8d5864406c53c5ea83aa7bfb94c47d">reset</a>();</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;        h.<a class="code" href="class_hash.html#a86ad3dcd18b0b279d4039e4404a1043c">put_block</a>(decom, 1);</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;        h.<a class="code" href="class_hash.html#a4bb9da7bf411c5db9af391fc3ec74f81">put</a>(message, nbytes);</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;        <a class="code" href="group___b_p.html#ga76fbd0364c5ce56d51e33dbf4adc3643">Com</a> res;</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;        h.<a class="code" href="class_hash.html#a574b6b0ef1b80eb4b15809cc15257a3f">digest</a>(res);</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        <span class="keywordflow">return</span> strncmp(com, res, <a class="code" href="class_hash.html#afd43dfd1a98f58dd6ea17eb3bba8a6c2">Hash::DIGEST_SIZE</a>)==0;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;    }</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;};</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#endif// COM_H__</span></div><div class="ttc" id="class_hash_html_a9c8d5864406c53c5ea83aa7bfb94c47d"><div class="ttname"><a href="class_hash.html#a9c8d5864406c53c5ea83aa7bfb94c47d">Hash::reset</a></div><div class="ttdeci">void reset()</div><div class="ttdef"><b>Definition:</b> hash.h:45</div></div>
<div class="ttc" id="class_commitment_html"><div class="ttname"><a href="class_commitment.html">Commitment</a></div><div class="ttdef"><b>Definition:</b> com.h:13</div></div>
<div class="ttc" id="class_commitment_html_abd804e39d27332e2928c636831b7fe1c"><div class="ttname"><a href="class_commitment.html#abd804e39d27332e2928c636831b7fe1c">Commitment::h</a></div><div class="ttdeci">Hash h</div><div class="ttdef"><b>Definition:</b> com.h:14</div></div>
<div class="ttc" id="garble_2block_8h_html_a65abbf31b0a30290189cdb5059b5f785"><div class="ttname"><a href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a></div><div class="ttdeci">__m128i block</div><div class="ttdef"><b>Definition:</b> block.h:8</div></div>
<div class="ttc" id="hash_8h_html"><div class="ttname"><a href="hash_8h.html">hash.h</a></div></div>
<div class="ttc" id="class_hash_html_a86ad3dcd18b0b279d4039e4404a1043c"><div class="ttname"><a href="class_hash.html#a86ad3dcd18b0b279d4039e4404a1043c">Hash::put_block</a></div><div class="ttdeci">void put_block(const block *block, int nblock=1)</div><div class="ttdef"><b>Definition:</b> hash.h:35</div></div>
<div class="ttc" id="class_hash_html_a4bb9da7bf411c5db9af391fc3ec74f81"><div class="ttname"><a href="class_hash.html#a4bb9da7bf411c5db9af391fc3ec74f81">Hash::put</a></div><div class="ttdeci">void put(const void *data, int nbyte)</div><div class="ttdef"><b>Definition:</b> hash.h:23</div></div>
<div class="ttc" id="class_p_r_g_html_a822a2e39f1d2629b881ce9b3b8d66bf9"><div class="ttname"><a href="class_p_r_g.html#a822a2e39f1d2629b881ce9b3b8d66bf9">PRG::random_block</a></div><div class="ttdeci">void random_block(block *data, int nblocks=1)</div><div class="ttdef"><b>Definition:</b> prg.h:75</div></div>
<div class="ttc" id="prg_8h_html"><div class="ttname"><a href="prg_8h.html">prg.h</a></div></div>
<div class="ttc" id="group___b_p_html_ga76fbd0364c5ce56d51e33dbf4adc3643"><div class="ttname"><a href="group___b_p.html#ga76fbd0364c5ce56d51e33dbf4adc3643">Com</a></div><div class="ttdeci">char Com[20]</div><div class="ttdef"><b>Definition:</b> com.h:10</div></div>
<div class="ttc" id="group___b_p_html_gad6ff8abfdae07ce92ed2245f801fec34"><div class="ttname"><a href="group___b_p.html#gad6ff8abfdae07ce92ed2245f801fec34">Decom</a></div><div class="ttdeci">block Decom[1]</div><div class="ttdef"><b>Definition:</b> com.h:11</div></div>
<div class="ttc" id="class_p_r_g_html"><div class="ttname"><a href="class_p_r_g.html">PRG</a></div><div class="ttdef"><b>Definition:</b> prg.h:16</div></div>
<div class="ttc" id="class_hash_html"><div class="ttname"><a href="class_hash.html">Hash</a></div><div class="ttdef"><b>Definition:</b> hash.h:12</div></div>
<div class="ttc" id="class_hash_html_a574b6b0ef1b80eb4b15809cc15257a3f"><div class="ttname"><a href="class_hash.html#a574b6b0ef1b80eb4b15809cc15257a3f">Hash::digest</a></div><div class="ttdeci">void digest(char *a)</div><div class="ttdef"><b>Definition:</b> hash.h:38</div></div>
<div class="ttc" id="class_commitment_html_a5453ed33018f54af82ffedb25d711d66"><div class="ttname"><a href="class_commitment.html#a5453ed33018f54af82ffedb25d711d66">Commitment::open</a></div><div class="ttdeci">bool open(Decom decom, Com com, const void *message, int nbytes)</div><div class="ttdef"><b>Definition:</b> com.h:24</div></div>
<div class="ttc" id="class_hash_html_afd43dfd1a98f58dd6ea17eb3bba8a6c2"><div class="ttname"><a href="class_hash.html#afd43dfd1a98f58dd6ea17eb3bba8a6c2">Hash::DIGEST_SIZE</a></div><div class="ttdeci">static const int DIGEST_SIZE</div><div class="ttdef"><b>Definition:</b> hash.h:17</div></div>
<div class="ttc" id="class_commitment_html_a2149ce3516c3454b803ab97f45439a6e"><div class="ttname"><a href="class_commitment.html#a2149ce3516c3454b803ab97f45439a6e">Commitment::commit</a></div><div class="ttdeci">void commit(Decom decom, Com com, const void *message, int nbytes)</div><div class="ttdef"><b>Definition:</b> com.h:16</div></div>
<div class="ttc" id="class_commitment_html_a63ff1008e7b57827062ad4f290478ef3"><div class="ttname"><a href="class_commitment.html#a63ff1008e7b57827062ad4f290478ef3">Commitment::prg</a></div><div class="ttdeci">PRG prg</div><div class="ttdef"><b>Definition:</b> com.h:15</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_eec959d81771dc8b1a750b834e1341eb.html">emp-tool</a></li><li class="navelem"><a class="el" href="dir_363cbed62d1567d90b8cbb6bda69428f.html">utils</a></li><li class="navelem"><a class="el" href="com_8h.html">com.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.12 </li>
  </ul>
</div>
</body>
</html>
